package l.l.w.practice.numOfLCS;

import java.util.*;

/**
 * Created by llw on 2017/10/3.
 */
public class NumOfLCS {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String line = scanner.nextLine();
        int result = new NumOfLCS().getNumOfLCS(line);
        System.out.println(result);
    }

    public int getNumOfLCS(String line) {
        Set<String> set = new HashSet<>();
        Set<String> fail = new HashSet<>();
        set.add(line);
        StringBuilder sb = null;
        for(int i = 0 ; i < line.length(); ++i){
            sb = new StringBuilder(line);
            sb.delete(i,i+1);
            for(int j =0; j <line.length();++j){
                sb.insert(j,line.charAt(i));
                String str = sb.toString();
                if(!set.contains(str) && !fail.contains(str)) {
                    if (isMatch(str)) {
                        set.add(str);
                    }else{
                        fail.add(str);
                    }

                }
                sb.delete(j, j + 1);
            }
        }
        return set.size()-1;
    }

    private boolean isMatch(String s) {
        Stack stack = new Stack<Character>();
        for(int i = 0 ; i < s.length(); ++i){
            if(s.charAt(i)=='('){
                stack.push(s.charAt(i));
            }else{
                if(stack.isEmpty()) {
                    return false;
                }
                stack.pop();
            }
        }
        if(stack.isEmpty()) return true;
        else return false;
    }
}
